From: Joey Hess Date: Fri, 3 Jan 2025 19:45:42 +0000 (-0400) Subject: log: Support --key, as well as --branch and --unused X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~10^2~56 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=0815c82bb1461d7763edbadce50d56cf662f25dc;p=git-annex.git log: Support --key, as well as --branch and --unused --all remains a special case, since it is more efficient and displays in a nicer order. Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project --- diff --git a/CHANGELOG b/CHANGELOG index d0c23b2b19..e6a89262c3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ git-annex (10.20250103) UNRELEASED; urgency=medium * Improve handing of ssh connection problems during remote annex.uuid discovery. + * log: Support --key, as well as --branch and --unused. -- Joey Hess Fri, 03 Jan 2025 14:30:38 -0400 diff --git a/Command/Log.hs b/Command/Log.hs index 73ae37061c..8dbbb77247 100644 --- a/Command/Log.hs +++ b/Command/Log.hs @@ -46,7 +46,7 @@ cmd = withAnnexOptions [jsonOptions, annexedMatchingOptions] $ data LogOptions = LogOptions { logFiles :: CmdParams - , allOption :: Bool + , keyOptions :: Maybe KeyOptions , sizesOfOption :: Maybe (DeferredParse UUID) , sizesOption :: Bool , totalSizesOption :: Bool @@ -62,11 +62,7 @@ data LogOptions = LogOptions optParser :: CmdParamsDesc -> Parser LogOptions optParser desc = LogOptions <$> cmdParams desc - <*> switch - ( long "all" - <> short 'A' - <> help "display location log changes to all files" - ) + <*> optional parseKeyOptions <*> optional ((parseUUIDOption <$> strOption ( long "sizesof" <> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID) @@ -138,22 +134,24 @@ seek o = ifM (null <$> Annex.Branch.getUnmergedRefs) zone <- liftIO getCurrentTimeZone outputter <- mkOutputter m zone o <$> jsonOutputEnabled let seeker = AnnexedFileSeeker - { startAction = const $ start o outputter + { startAction = const $ \si file key -> + start o outputter (si, key, mkActionItem (file, key)) , checkContentPresent = Nothing -- the way this uses the location log would not be -- helped by precaching the current value , usesLocationLog = False } - case (logFiles o, allOption o) of - (fs, False) -> withFilesInGitAnnex ww seeker + case (logFiles o, keyOptions o) of + ([], Just WantAllKeys) -> + commandAction (startAll o outputter) + (fs, ko) -> withKeyOptions ko False + seeker (commandAction . start o outputter) + (withFilesInGitAnnex ww seeker) =<< workTreeItems ww fs - ([], True) -> commandAction (startAll o outputter) - (_, True) -> giveup "Cannot specify both files and --all" -start :: LogOptions -> (ActionItem -> SeekInput -> Outputter) -> SeekInput -> RawFilePath -> Key -> CommandStart -start o outputter si file key = do +start :: LogOptions -> (ActionItem -> SeekInput -> Outputter) -> (SeekInput, Key, ActionItem) -> CommandStart +start o outputter (si, key, ai) = do (changes, cleanup) <- getKeyLog key (passthruOptions o) - let ai = mkActionItem (file, key) showLogIncremental (outputter ai si) changes void $ liftIO cleanup stop diff --git a/doc/git-annex-log.mdwn b/doc/git-annex-log.mdwn index 68f749b241..8432ce1011 100644 --- a/doc/git-annex-log.mdwn +++ b/doc/git-annex-log.mdwn @@ -38,6 +38,18 @@ false, information may not have been committed to the branch yet. In this mode, the names of files are not available and keys are displayed instead. +* `--key=keyname` + + Displays the location log for the specified key. + +* `--branch=ref` + + Displays the location log for the files in the specified branch or treeish. + +* `--unused` + + Displays the location log for files found by last run of git-annex unused. + * `--sizesof=repository` Displays a history of the total size of the annexed files in a repository diff --git a/doc/todo/add_--key_to___34__annex_log__34__.mdwn b/doc/todo/add_--key_to___34__annex_log__34__.mdwn index fdeb6062b6..a49bf3ef65 100644 --- a/doc/todo/add_--key_to___34__annex_log__34__.mdwn +++ b/doc/todo/add_--key_to___34__annex_log__34__.mdwn @@ -13,3 +13,5 @@ In my case -- doing archaeology on AFNI's test data in [https://github.com/afni/ [[!meta author=yoh]] [[!tag projects/repronim]] + +> [[done]] --[[Joey]]